package com.example.docking.util;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;


public class Decrypt {
    public static String decrypt(String data) throws Exception {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        SecretKeySpec skeySpec = new SecretKeySpec(Constants.CLIENT_SECRET.getBytes("ASCII"), "AES");
        IvParameterSpec iv = new IvParameterSpec("5e8y6w45ju8w9jq8".getBytes());
        cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
        byte[] buffer = Base64.getDecoder().decode(data);
        byte[] encrypted = cipher.doFinal(buffer);
        return new String(encrypted, "UTF-8");
    }
}
